﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using COFE.Core;

namespace COFE.Core
{
    public class EntryListManager : IEntryListManager
    {
        #region Constructors

        public EntryListManager(IUserProfile userProfile)
        {
            _userProfile = userProfile;
        }

        #endregion

        #region Methods

        public IEntryList GetList(string name)
        {
            return COFEShared.EntryListRegistrar[name];
        }

        public void RemoveEntryList(string name)
        {
            var entryList = GetList(name);
            if (entryList == null)
                throw new KeyNotFoundException(name);

            COFEShared.EntryListRegistrar.RemoveEntryList(name);
        }

        public void RegisterEntryList(IEntryList entryList)
        {
            COFEShared.EntryListRegistrar.RegisterEntryList( entryList);            
        }

        public ICustomEntryList CreateCustomEntryList(string name)
        {
            return new CustomEntryList(name);
        }

        public IAutoEntryList CreateAutoEntryList(string name, 
            IDirectoryInfo rootDir, string filterString)
        {
            return new AutoEntryList(Guid.NewGuid(), name, rootDir, filterString);
        }

        public IAutoEntryList CreateAutoEntryList(string name, string filterString)
        {
            return new AutoEntryList(Guid.NewGuid(), name, filterString);
        }

        #endregion

        #region Data

        IUserProfile _userProfile;

        #endregion

        #region Public Properties

        public IEntryList this[string name] { get { return GetList(name); } }

        public string[] EntryLists { get { return COFEShared.EntryListRegistrar.GetEntryLists(); } }

        #endregion






       
    }
}
